﻿using System;
using System.Reflection;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Linq;

namespace BizControl.Library
{
  public class Version
  {
    public static string BizControlVersion
    {
      get
      {
        //NameValueCollection appSettings = ConfigurationManager.AppSettings;
        StringBuilder sb = new StringBuilder();
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
        Attribute attribute = (attributes.SingleOrDefault()) as AssemblyTitleAttribute;
        if (attribute != null)
          sb.Append((attribute as AssemblyTitleAttribute).Title);
        sb.Append(Environment.NewLine);
        attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true);
        attribute = (attributes.SingleOrDefault()) as AssemblyCopyrightAttribute;
        if (attribute != null)
          sb.Append((attribute as AssemblyCopyrightAttribute).Copyright);
        return sb.ToString();
      }
    }

    public static string BizControlAuthors
    {
      get
      {
        StringBuilder sb = new StringBuilder();
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
        Attribute attribute = (attributes.SingleOrDefault()) as AssemblyCompanyAttribute;
        if (attribute != null)
          sb.Append((attribute as AssemblyCompanyAttribute).Company);
        return sb.ToString();
      }
    }
  }
}
